package tianrun.ziguan.api.calculate.config.service.template.module.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import tianrun.ziguan.api.calculate.config.dao.TStaticPropertiesModuleMapper;
import tianrun.ziguan.api.calculate.config.entity.TStaticPropertiesModule;
import tianrun.ziguan.api.calculate.config.service.template.module.ITStaticPropertiesModuleService;
import tianrun.ziguan.api.calculate.config.utils.CollectionUtil;

import java.util.Collections;
import java.util.List;
import java.util.Set;

@Service
public class ITStaticProperTiesModuleServiceImpl extends ServiceImpl<TStaticPropertiesModuleMapper, TStaticPropertiesModule> implements ITStaticPropertiesModuleService {
    @Override
    public List<TStaticPropertiesModule> getByTemplate(Set<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return list(Wrappers.<TStaticPropertiesModule>lambdaQuery().eq(TStaticPropertiesModule::getIsValid, true).in(TStaticPropertiesModule::getTemplateId, ids));
    }

    @Override
    public List<TStaticPropertiesModule> getByIds(Set<Long> moduleIds) {
        if (CollectionUtil.isEmpty(moduleIds)) {
            return Collections.emptyList();
        }
        return list(Wrappers.<TStaticPropertiesModule>lambdaQuery().eq(TStaticPropertiesModule::getIsValid, true).in(TStaticPropertiesModule::getId, moduleIds));

    }
}
